package kernel

import (
	. "data/datatype"
	"share/msg"
)

type objpacker interface {
	GetRec(rec string) interface{}
}

type proppacker interface {
	Get(p string) (val interface{}, err error)
	Type(p string) (int, string, error)
	GetDirty() map[string]interface{}
	ClearDirty()
}

type recpacker interface {
	Get(row, col int) (val interface{}, err error)
	ColTypes() ([]int, []string)
	Rows() int
	Dirty() bool
}

type GameObjecter interface {
	GetDataType() string
	SetKernel(kernel *Kernel)
	Kernel() *Kernel
	SetData(data interface{})
	GetName() string
	SetNameHash(hash int32)
	GetNameHash() int32
	GetData() interface{}
	SetDBId(id int64)
	GetDBId() int64
	SetType(name string)
	GetType() string
	SetObjId(id ObjectID)
	GetObjId() *ObjectID
	GetRegionId() int32
	IsDel() bool
	Delete()

	//container
	SetParent(p GameObjecter)
	Parent() GameObjecter
	SetCapacity(c int)
	RemoveChild(child GameObjecter) bool
	AddChild(index int, child GameObjecter) int

	//callback
	callee
}

type Serializer interface {
	LoadFromDB(data *msg.DbPack)
	Serialize() *msg.DbPack
}

type callee interface {
	//创建类时回调
	OnCreateClass()
	//对象创建
	OnCreate()
	//对象被销毁
	OnDestroy()
	//增加子对象测试，通过返回1
	OnTestAdd(child GameObjecter) int
	//增加子对象
	OnAdd(child GameObjecter)
	//移除子对象
	OnRemove(child GameObjecter)
	//进入父对象
	OnEntry(parent GameObjecter)
	//离开父对象
	OnLeave(parent GameObjecter)
}
